import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DeleteStu extends Dialog implements WindowListener, ActionListener {
    private static final long serialVersionUID = 1L;
    private TextField t1;
    private Button b1, b2;

    public DeleteStu(Frame owner) {
        super(owner);
        this.setTitle("学生退学或毕业");
        this.setBounds(100, 100, 300, 300);

        setLayout(new BorderLayout());

        Panel p = new Panel();
        p.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20));
        Label m1 = new Label("学生学号：");
        p.add(m1);
        t1 = new TextField(15);
        p.add(t1);

        //p.setBorder(new MatteBorder(0,0,0,0,Color.BLACK));

        add(p, BorderLayout.CENTER);

        Panel p2 = new Panel();
        p2.setLayout(new FlowLayout(FlowLayout.RIGHT));
        this.b1 = new Button("确定");
        this.b1.addActionListener(this);
        this.b2 = new Button("取消");
        this.b2.addActionListener(this);
        p2.add(b1);
        p2.add(Box.createHorizontalStrut(20));
        p2.add(b2);
        p2.add(Box.createHorizontalStrut(20));
        add(p2, BorderLayout.SOUTH);


        //this.addWindowListener(this);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                dispose();

            }
        });
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (b1 == e.getSource()) {
            String f1 = t1.getText();
            //Order_gp A=new Order_gp(gno,pno,Integer.parseInt(num));
            DBconnect b = new DBconnect();
            b.delete_Student(f1);
        }
        dispose();
    }

    @Override
    public void windowActivated(WindowEvent e) {
    }

    @Override
    public void windowClosed(WindowEvent e) {
        dispose();
    }

    @Override
    public void windowClosing(WindowEvent e) {
        dispose();
    }

    @Override
    public void windowDeactivated(WindowEvent e) {
    }

    @Override
    public void windowDeiconified(WindowEvent e) {
    }

    @Override
    public void windowIconified(WindowEvent e) {
    }

    @Override
    public void windowOpened(WindowEvent e) {
    }

}
